﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="avatar.aspx.cs" Inherits="VISS.Web.Frontend.Modules.User.Profile.AvatarPage" %>
<%@ Register Src="~/modules/user/profiles/controls/avatarPopup.ascx" TagName="avatarUpload" TagPrefix="viss" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Thay đổi Avatar</title>
    <link rel="stylesheet" type="text/css" href="<%=AppSettings.ResourcesPath %>/styles/avatar.css?rand=20110113" />
    <script src="<%=AppSettings.ResourcesPath %>/scripts/lib/jquery/jquery-1.4.2.min.js?rand=20110113" type="text/javascript"></script>
    <script src="<%=AppSettings.ResourcesPath %>/scripts/lib/jquery/jquery.filestyle.js?rand=20110113" type="text/javascript"></script>
    <script src="<%=AppSettings.ResourcesPath %>/scripts/lib/jquery/jquery.alerts.js?rand=20110113" type="text/javascript"></script>
    <script src="<%=AppSettings.ResourcesPath %>/scripts/exec/constants.js?rand=20110113" type="text/javascript"></script>
    <script type="text/javascript">
        var GLOBAL_ROOT_URL = '<%= AppSettings.RootURL %>';
        var GLOBAL_RESOURCES_PATH = '<%= AppSettings.ResourcesPath %>';
        
        function upload() {
            document.forms["formavatar"].setAttribute("action", "/api/user.ashx");
            document.getElementById("action-request").setAttribute("name", "action");
            document.getElementById("ajaxloader").style.display = 'block';
            document.forms["formavatar"].submit();
        }

        function uploadAvatarComplete(result, imgPath) {
            if (result == "1" || result == "-1" || result == "0") {
                window.parent.uploadAvatarComplete(result, imgPath);
                return;
            }
            
            if (result == "2") {
                jAlert(ImageRateError);
            }
            else if (result == "3") {
                jAlert(ImageFileSizeError);
            }
            else if (result == "4") {
                jAlert(ImageSizeError);
            }
            else if (result == "5") {
                jAlert(ImageFileExtensionError);
            }
            document.getElementById("ajaxloader").style.display = 'none';
        }

        $(document).ready(function() {
            $("#Avatar").filestyle({
                image: GLOBAL_RESOURCES_PATH + "/images/button-browse.jpg",
                imageheight: 25,
                imagewidth: 80,
                width: 280
            });
        });
        
    </script>
</head>
<body>
    <form id="formavatar" action="" method="post" enctype="multipart/form-data" encoding="multipart/form-data" target="UploadWindow" runat="server">
        <div id="avatar-popup">
            <viss:avatarUpload ID="idAvatar" runat="server" EnableViewState="false" />
        </div>
        <input type="hidden" id="action-request" name="actiontemp" value="changeAvatar" />
    </form>
    <iframe id="UploadWindow" name="UploadWindow" width="0" height="0" style="display: none;" src="javascript:void(0)"></iframe>
    
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-273986-1']);
      _gaq.push(['_trackPageview']);
      (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    </script>
</body>
</html>
